package com.allinpay.merchantweb.common.utils;

import java.security.PrivateKey;
import java.security.PublicKey;

import org.bouncycastle.util.encoders.Base64;

public class Test {
	public static void main(String[] args) throws Exception {
		/*PublicKey publicKey = SecurityUtils.getPublicKey("009e290c04f619cea309bc53873e89d8daf02a05f752013ef7996e51d76aedd36d0eebb069e406fc67210967c80a84ba4987ad5cb9c5ca4d2e2fc81a8bd1680bec28e825842485b7dcb002b996c4d0d4f70184401c863227e82e28be4aa51e366b52885d633299a8fbbca86260b6085db8d7077b9011aa72403e9d634c20ce95e8fae7fe4449d51bf72cf163e905ae701b067010519f94d1cc571439d36745c39d35c1ba9e9d4cfe2ab0dfb740e2ee62cbc76a0050f4122ee309307b35b63bdd585930762b9894d7a11b06d96d1672a89af07d969a47c0d89caaf7baad3c2577863b8873c5c3e080d551d60ed54f86ec8821b26abec4305f43c4ab0d887e70758b", "010001");
		System.out.println("publicKey===");
		
		PrivateKey privateKey = SecurityUtils.getPrivateKey("009e290c04f619cea309bc53873e89d8daf02a05f752013ef7996e51d76aedd36d0eebb069e406fc67210967c80a84ba4987ad5cb9c5ca4d2e2fc81a8bd1680bec28e825842485b7dcb002b996c4d0d4f70184401c863227e82e28be4aa51e366b52885d633299a8fbbca86260b6085db8d7077b9011aa72403e9d634c20ce95e8fae7fe4449d51bf72cf163e905ae701b067010519f94d1cc571439d36745c39d35c1ba9e9d4cfe2ab0dfb740e2ee62cbc76a0050f4122ee309307b35b63bdd585930762b9894d7a11b06d96d1672a89af07d969a47c0d89caaf7baad3c2577863b8873c5c3e080d551d60ed54f86ec8821b26abec4305f43c4ab0d887e70758b", "54a304a2970c426f2f238fd37d1d0966484544c210294887f99c76c17fa05b972df7e4851618c2f37153762d2fabcd80d1d16d20a0fedc848ddf588d5ff77d01d8f63a3557d2130d4f4776077fb57d71dd66e7641c5034d8e3f2bbba78580da92b167c5b3c55cc7f427b1d82418782980ac21f567e8da6ec4855b330a711c6587a51b3fd9ce0390c7875c92bc0bb35fabbb14e605e4ea705206ceef38ed462d0cccc7d8c45cd7aec319d21aca88fadc2b17e07c518e062785d9a3b1a30840a2a0477dfb1ed049e1f5f02ad045824e850c2f9cbc6443b29ea6bf965e08dfdc348b3c76e722c36d622c306056f8eac049958509ee7435088a7f456f35e8a1e6371");
		System.out.println("publicKey===");*/
		
		PublicKey publicKey = SecurityUtils.getPublicKey("00a287e3f1e99551c6a71a391f375a1f7977676d6701922d32b2101cb4f1df84a13163c2b895890eced6b63b96c252d0a98345c6dec536eac63bb7a02409f691200d6cd3ca0ba66940d6d2c7905dc9e3eb14326c4b37b8f728afcfc95d2ecf282af6d8540cf4c5bf278de678172ae319832eb01dc4db418b80cb99f1ef4b42260e5a522b3103bc4664cf2f53d1aced6612a16f8eaecf09e86129a1eafc7230bc108492b4cd2c0c6aa66e99edfb7dbafd8cb1625f4c0c39298d2fc02a9581b614c3dada7bcb83c87557cc709cc52211c65e4fa374284bb4b7864df3d9bfdb9e52d39c70b3f86884c46099314c0c02965f8a33130dd80c6aa672984f49b183560709", "010001");
		System.out.println("publicKey===");
		
		PrivateKey privateKey = SecurityUtils.getPrivateKey("00a287e3f1e99551c6a71a391f375a1f7977676d6701922d32b2101cb4f1df84a13163c2b895890eced6b63b96c252d0a98345c6dec536eac63bb7a02409f691200d6cd3ca0ba66940d6d2c7905dc9e3eb14326c4b37b8f728afcfc95d2ecf282af6d8540cf4c5bf278de678172ae319832eb01dc4db418b80cb99f1ef4b42260e5a522b3103bc4664cf2f53d1aced6612a16f8eaecf09e86129a1eafc7230bc108492b4cd2c0c6aa66e99edfb7dbafd8cb1625f4c0c39298d2fc02a9581b614c3dada7bcb83c87557cc709cc52211c65e4fa374284bb4b7864df3d9bfdb9e52d39c70b3f86884c46099314c0c02965f8a33130dd80c6aa672984f49b183560709", "3d3e456767a42b6f56922c0a163a7077bdc58c54ef239cc2689467accb23757fa3f3ba71016fe6d38bd69937a2bbc002d0035fff9b82a90ecf7bceed258ff2798875848cb2bd1f161e9cc8341f132f3dea9b61712a6b193f0c989880f35d7dfe4a8b93885a4795531b4647e43af5de2c2f508fb7190366c4be73a0d5919f38653ddb851e7826dbd4ca6b0b6702ee00a7c6a11e7ef34a844565d1af2a0814b7619293c9dc7606c6eae08ef6f6b10495d5b16dd98ca397db2705c46dc189a65a90198901938132a46d845862a81253d39313701c72aee2624534ba2a36af8849632aebba919754a36979567ecdf226d76732fdb371f94a3eef3bfc2e94dcaeb781");
		System.out.println("privateKey===");
		
		String signSrc ="C0B5986835E635E3090F13EC9EB4F656";
		
		//签名
		String signMac=new String(Base64.encode(SecurityUtils.signByPriKey(privateKey,signSrc.getBytes(),"MD5WithRSA")));
		System.out.println("签名："+signMac);
		
		//验签
		boolean result=SecurityUtils.verifyByPubKey(publicKey,signSrc.getBytes(),Base64.decode(signMac),"MD5WithRSA");
		System.out.println("验证结果："+result);
	}
}
